package com.abou.manager.common;

import javax.servlet.ServletContext;
import com.abou.constant.product.EClotheType;
import com.abou.constant.product.EProductType;
import com.abou.constant.product.ESortOrder;
import com.abou.model.common.product.Product;
import com.abou.model.common.product.search.SearchProductsResult;

/**
 * The interface defining the method used to manage products.
 * 
 * @author khalid
 */
public interface IProductManager {
  
  /**
   * Creates and persists a product in the database.
   * 
   * @param product The product to create
   * @return The created product
   */
  Product createProduct(Product product, ServletContext context)
      throws Exception;
  
  /**
   * Updates the product in the database.
   * 
   * @param product The product with updated data
   * @return The updated product
   */
  Product updateProduct(Product product, ServletContext context)
      throws Exception;
  
  /**
   * Returns the product corresponding to the passed ID.
   * 
   * @param id The product ID.
   * @return The product
   */
  Product getProduct(int id);
  
  /**
   * Returns the search products result.
   * 
   * @param sortOrder The sort order
   * @param pageIndex The page index
   * @param pageSize The page size
   * @return All the products that can be found in the database.
   */
  SearchProductsResult listAllProducts(ESortOrder sortOrder, int pageIndex,
      int pageSize);
  
  /**
   * Returns all the products matching the passed parameters.
   * 
   * @param name A name identifier.
   * @param description A product description identifier.
   * @param type A type identifier.
   * @param sortOrder The sort order
   * @param pageIndex The page index
   * @param pageSize The page size
   * @return All the products that can be found in the database matching the
   *         passed parameters.
   */
  SearchProductsResult listProducts(String name, String description,
      EProductType type, ESortOrder sortOrder, int pageIndex, int pageSize);
  
  /**
   * Returns all the products matching the passed parameters.
   * 
   * @param name A name identifier.
   * @param description A product description identifier.
   * @param sortOrder The sort order
   * @param pageIndex The page index
   * @param pageSize The page size
   * @return All the products that can be found in the database matching the
   *         passed parameters.
   */
  SearchProductsResult listProductsByNameDescription(String name,
      String description, ESortOrder sortOrder, int pageIndex, int pageSize);
  
  /**
   * Returns all the products for the passed name.
   * 
   * @param name A name identifier.
   * @param sortOrder The sort order
   * @param pageIndex The page index
   * @param pageSize The page size
   * @return A products list
   */
  SearchProductsResult findProductByName(String name, ESortOrder sortOrder,
      int pageIndex, int pageSize);
  
  /**
   * Returns all the products for the passed description.
   * 
   * @param description A product description identifier.
   * @param sortOrder The sort order
   * @param pageIndex The page index
   * @param pageSize The page size
   * @return A products list
   */
  SearchProductsResult findProductByDescription(String description,
      ESortOrder sortOrder, int pageIndex, int pageSize);
  
  /**
   * Returns all the products for the passed type.
   * 
   * @param type A type identifier.
   * @param sortOrder The sort order
   * @param pageIndex The page index
   * @param pageSize The page size
   * @return A products list
   */
  SearchProductsResult findProductByType(EProductType type,
      ESortOrder sortOrder, int pageIndex, int pageSize);
  
  /**
   * Deletes the product denoted by the passed ID.
   * 
   * @param id A product ID
   * @throws Exception
   */
  void deleteProduct(int id) throws Exception;
  
  /**
   * Returns all the products for the passed params.
   * 
   * @param name The name identifier.
   * @param description The product description identifier.
   * @param productType The product type
   * @param clotheType The clothes type
   * @param sortOrder The sort order
   * @param pageIndex The page index
   * @param pageSize The page size
   * @return A products list
   */
  SearchProductsResult listProductsClothes(String name, String description,
      EProductType productType, EClotheType clotheType, ESortOrder sortOrder,
      int pageIndex, int pageSize);
}
